package org.algorithm.biubiu.wheel_2.链表;

import org.algorithm.common.ListNode;


public class 反转链表 {


    public ListNode reverseList(ListNode head) {
        if(head==null) return head;
        ListNode pre = head;
        ListNode nextNode = pre.next;
        pre.next = null;
        while(nextNode!=null){
            ListNode next = nextNode.next;
            nextNode.next = pre;
            pre = nextNode;
            nextNode =next;

        }
        return pre;

    }
}
